function appendToScreen(value) {
  document.getElementById('screen').value += value;
}

function calculate(operator) {
  const screen = document.getElementById('screen');
  screen.value = screen.value + operator;
}

function clearScreen() {
  document.getElementById('screen').value = '';
}

function backspace() {
  const screen = document.getElementById('screen');
  screen.value = screen.value.slice(0, -1);
}

function equals() {
  try {
      const screen = document.getElementById('screen');
      const result = eval(screen.value);
      screen.value = result;
  } catch (e) {
      alert('错误: 无效的输入');
  }
}